package com.study.base.mutilthread.interrupt;

/**
 * Description:
 * User: 27010
 * DateTime: 2017/9/10 0:06
 */
public class InteruptTest {
    public static void main(String[] args) {
        Thread dealInterruptedThread = new Thread(new DealInterrupted());
        Thread interuptThreadThread = new Thread(new InteruptThread(dealInterruptedThread));

        dealInterruptedThread.start();
        interuptThreadThread.start();
    }
}

class InteruptThread implements Runnable {

    private Thread thread;

    public InteruptThread(Thread thread) {
        this.thread = thread;
    }

    @Override
    public void run() {
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        thread.interrupt();
    }
}

class DealInterrupted implements Runnable {
    @Override
    public void run() {
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
           // Thread.currentThread().interrupt();  好像加不加这一句没啥区别啊???    
            e.printStackTrace();
        }

        System.out.print("222");
    }
}
